home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / pascal / swag / keyboard.swg / 0049_Disable Ctrl-Break.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1993-11-02  |  1.9 KB  |  66 lines

  1. (*
  2. LOU DUCHEZ
  3.  
  4. >> How can i disable the Pascal interrupt key Ctrl-Break?
  5.  
  6. >Try CheckBreak := False;
  7.  
  8. > Isn't there another way to do this that works better? Just wondering... :)
  9.  
  10. Well, here's some code I came up With.  What it does is "cheat": it
  11. detects if you're pressing "C" While "Ctrl" is down.  if so, it changes
  12. "Ctrl" to "undepressed".  As For "Ctrl-Break", I just changed the
  13. built-in "Ctrl-Break" interrupt to an "empty" routine (i.e., it does
  14. NOTHING).  And it's a TSR, too; to "un-TSR" the code, remove the
  15. "{$M ...}" at the beginning and the "keep(0)" at the end, then just
  16. incorporate the code into your Programs.  More comments as I go:
  17. *)
  18.  
  19. {$M $0400, $0000, $0000}
  20. {$F+}
  21.  
  22. Program nobreak;
  23. Uses
  24.   Dos;
  25.  
  26. Const
  27.   ctrlByte = $04;  { Memory location $0040:$0017 governs the statUses of
  28.                      the Ctrl key, Alt, Shifts, etc.  the "$04" bit
  29.                      handles "Ctrl". }
  30.  
  31. Var
  32.   old09h       : Procedure; { original keyboard handler }
  33.   ctrldown,
  34.   cdown        : Boolean;
  35.   keyboardstat : Byte Absolute $0040:$0017;    { the aforementioned location }
  36.  
  37. Procedure new1bh; interrupt;  { new Ctrl-Break handler: does NOTHING }
  38. begin
  39. end;
  40.  
  41. Procedure new09h; interrupt;  { new keyboard handler: it checks if you've
  42.                                 pressed "C" or "Brk"; if you have, it changes
  43.                                 "Ctrl" to "undepressed.  Then it calls the
  44.                                 "old" keyboard handler. }
  45. begin
  46.   if port[$60] and $1d = $1d then
  47.     ctrldown := (port[$60] < 128);
  48.   if port[$60] and $2e = $2e then
  49.     cdown := (port[$60] < 128);
  50.   if cdown and ctrldown then
  51.     keyboardstat := keyboardstat and not ctrlByte;
  52.   Asm
  53.     pushf
  54.   end;
  55.   old09h;
  56. end;
  57.  
  58. begin
  59.   getintvec($09, @old09h);
  60.   setintvec($09, @new09h);  { set up new keyboard handler }
  61.   setintvec($1b, @new1bh);  { set up new "break" handler }
  62.   ctrldown := False;
  63.   cdown    := False;
  64.   keep(0);
  65. end.
  66.